function validateForm(){
	
	if (document.getElementById('categoryName').value == "Select"){
		alert("Please select a category.");
		return false;
	}
	
	if (document.getElementById('onsiteRate').value == null || document.getElementById('onsiteRate').value.length ==0){
		document.getElementById('onsiteRate').style.background = 'Yellow';
		alert("Onsite rate has not been filled in.");
		return false;
	}
	
	if (document.getElementById('offshoreRate').value == null || document.getElementById('offshoreRate').value.length ==0){
	    document.getElementById('offshoreRate').style.background = 'Yellow';
		alert("Offshore rate has not been filled in.");
		return false;
	}
	
	if(!validateRates()){
		return false;
		}
	    	
	    return true;
	
}

function validateRates(){
	  
	   var onsiteRate = document.getElementById('onsiteRate').value;
	   if(!isValidRate(onsiteRate,'Onsite Rate')){
	   document.getElementById('onsiteRate').style.background = 'Yellow';
	   return false;
	   }else{
	   document.getElementById('onsiteRate').style.background = 'white';
	   }
	  
	   var offshoreRate = document.getElementById('offshoreRate').value;
	   if(!isValidRate(offshoreRate,'Offshore Rate')){
	   document.getElementById('offshoreRate').style.background = 'Yellow';
	   return false;
	   }else{
	   document.getElementById('offshoreRate').style.background = 'white';
	   }
	  
	   return true; 
}	   

function isValidRate(rate , fld){

    var ValidChars = "0123456789.";
      var IsValidChar=true;
      var Char;
      var count = 0;
      
      for (i = 0; i < rate.length && IsValidChar == true; i++)
      {
         Char = rate.charAt(i);
         
         
         if(Char == ' '){
             alert(fld+" should not contain space.\n");
             return false;
         }
        
         
         if(Char == '.'){
             count =  count+1;
         }
         
         if(ValidChars.indexOf(Char) == -1 || count>1)
         {
         alert("Please enter valid rate in "+fld+".")
         return false;
         }
      }
   
      return true;

}


function enableFieldForUpdate() {
	document.getElementById("categoryName").disabled=false;
	document.getElementById("onsiteRate").disabled=false;
	document.getElementById("offshoreRate").disabled=false;
	document.getElementById("saveUpdateButton").style.display="block";
	document.getElementById("updateButton").style.display="none";
}

function displayRecords(theForm){
	document.forms["searchUpdateClientBilling"].action="clientBillingCategoryMaintenance.html?method=searchRelatedCategories";
	document.forms.searchUpdateClientBilling.submit();
	
}